﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
// Copyright (C) 2017 ZyCoder
// 版权所有。 
//
// 文件名：RegWindowViewModel
// 
// 创建者：名字 (zycoder)
// 时间：2018/4/8 11:00:11
//
// 版本：V1.0.0
// 网站: http://www.cnblogs.com/zycoder
//----------------------------------------------------------------*/
#endregion

using Prism.Commands;
using Prism.Mvvm;
using System;
using System.IO;

namespace TuTu.WpfApp.ViewModels
{
    public class RegWindowViewModel: BindableBase
    {
        private Random r = new Random();

        private int i = 0;

        private string[] _files;

        private string _filePath;

        public string FilePath
        {
            get { return _filePath; }
            set { _filePath = value;RaisePropertyChanged("FilePath"); }
        }

        public DelegateCommand ChangeImgCommand { get; set; }

        public RegWindowViewModel()
        {
            this._files= Directory.GetFiles(@"..\..\Resource\headImgs");
            this.i = r.Next(_files.Length);
            this._filePath = _files[i];
            this.ChangeImgCommand = new DelegateCommand(new Action (ChangeImgExcute));
        }

        public void ChangeImgExcute()
        {
            this.i = i == _files.Length - 1 ? 0 : ++i;            
            this.FilePath = _files[i];
        }
    }
}
